/**
 * Alipay.com Inc.
 * Copyright (c) 2004-2012 All Rights Reserved.
 */
package com.alipay.supergw.common.dal.share_supergw.auto.ibatis;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.alipay.supergw.common.dal.share_supergw.auto.daointerface.CommunicationRouteDAO;
import com.alipay.supergw.common.dal.share_supergw.auto.dataobject.CommunicationRouteDO;

/**
 * An ibatis based implementation of dao interface <tt>com.alipay.supergw.common.dal.share_supergw.auto.daointerface.CommunicationRouteDAO</tt>.
 *
 * This file is generated by <tt>supergw-dalgen</tt>, a DAL (Data Access Layer)
 * code generation utility specially developed for <tt>supergw</tt> project.
 * 
 * PLEASE DO NOT MODIFY THIS FILE MANUALLY, or else your modification may
 * be OVERWRITTEN by someone else. To modify the file, you should go to 
 * directory <tt>(project-home)/dalgen</tt>, and 
 * find the corresponding configuration file (<tt>tables/sgw_communication_route.xml</tt>). 
 * Modify the configuration file according to your needs, then run <tt>supergw-dalgen</tt> 
 * to generate this file.
 */
public class IbatisCommunicationRouteDAO extends SqlMapClientDaoSupport implements
                                                                       CommunicationRouteDAO {

    /**
     *  Query DB table <tt>sgw_communication_route</tt> for records.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>select out_trans_code_id, channel_system_id, uri_key, uri_addr, uri_weight, uri_type, memo, gmt_create, gmt_modified from sgw_communication_route</tt>
     *
     *	@return List<CommunicationRouteDO>
     *	@throws DataAccessException
     */
    @Override
    @SuppressWarnings("unchecked")
    public List<CommunicationRouteDO> loadAll() throws DataAccessException {

        return getSqlMapClientTemplate().queryForList("MS-COMMUNICATION-ROUTE-LOAD-ALL", null);

    }

    /**
     *  Insert one <tt>CommunicationRouteDO</tt> object to DB table <tt>sgw_communication_route</tt>, return primary key
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>insert into sgw_communication_route(out_trans_code_id,channel_system_id,uri_key,uri_addr,uri_weight,uri_type,memo,gmt_create,gmt_modified) values (?, ?, ?, ?, ?, ?, ?, ?, ?)</tt>
     *
     *	@param communicationRoute
     *	@return String
     *	@throws DataAccessException
     */
    @Override
    public String insert(CommunicationRouteDO communicationRoute) throws DataAccessException {
        if (communicationRoute == null) {
            throw new IllegalArgumentException("Can't insert a null data object into db.");
        }

        getSqlMapClientTemplate().insert("MS-COMMUNICATION-ROUTE-INSERT", communicationRoute);

        return communicationRoute.getOutTransCodeId();
    }

    /**
     *  Update DB table <tt>sgw_communication_route</tt>.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>update sgw_communication_route set channel_system_id=?, uri_addr=?, uri_weight=?, uri_type=?, memo=?, gmt_modified=? where ((out_trans_code_id = ?) AND (uri_key = ?))</tt>
     *
     *	@param communicationRoute
     *	@return int
     *	@throws DataAccessException
     */
    @Override
    public int updateByPK(CommunicationRouteDO communicationRoute) throws DataAccessException {
        if (communicationRoute == null) {
            throw new IllegalArgumentException("Can't update by a null data object.");
        }

        return getSqlMapClientTemplate().update("MS-COMMUNICATION-ROUTE-UPDATE-BY-PK",
            communicationRoute);
    }

    /**
     *  Update DB table <tt>sgw_communication_route</tt>.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>update sgw_communication_route set uri_weight=?, gmt_modified=? where (uri_addr LIKE ?)</tt>
     *
     *	@param communicationRoute
     *	@return int
     *	@throws DataAccessException
     */
    @Override
    public int updateByHost(CommunicationRouteDO communicationRoute) throws DataAccessException {
        if (communicationRoute == null) {
            throw new IllegalArgumentException("Can't update by a null data object.");
        }

        return getSqlMapClientTemplate().update("MS-COMMUNICATION-ROUTE-UPDATE-BY-HOST",
            communicationRoute);
    }

    /**
     *  Delete records from DB table <tt>sgw_communication_route</tt>.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>delete from sgw_communication_route where ((out_trans_code_id = ?) AND (uri_key = ?))</tt>
     *
     *	@param outTransCodeId
     *	@param uriKey
     *	@return int
     *	@throws DataAccessException
     */
    @Override
    @SuppressWarnings({ "rawtypes", "unchecked" })
    public int deleteByPK(String outTransCodeId, String uriKey) throws DataAccessException {
        Map param = new HashMap();

        param.put("outTransCodeId", outTransCodeId);
        param.put("uriKey", uriKey);

        return getSqlMapClientTemplate().delete("MS-COMMUNICATION-ROUTE-DELETE-BY-PK", param);
    }

}